package com.quick.develop.flowable.controller.process;

import com.quick.develop.framework.common.page.R;
import com.quick.develop.flowable.domain.entrust.BpmEntrustEx;
import com.quick.develop.flowable.domain.entrust.BpmEntrustExPageReqVO;
import com.quick.develop.flowable.domain.entrust.BpmEntrustInfoReqVO;
import com.quick.develop.flowable.service.process.IBpmEntrustExService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @author junyuan.liu
 * @description:
 * @date 2022/9/5 9:23
 */
@Api(tags = "流程管理后台 - 流程委托")
@RestController
@RequestMapping("/entrust")
@Validated
public class BpmEntrustController {
    @Resource
    IBpmEntrustExService bpmEntrustExService;

    @ApiOperation(value = "委托列表")
    @GetMapping("/myPage")
    public R<?> myPage(BpmEntrustExPageReqVO reqVO) {
        return R.ok(bpmEntrustExService.selectPage(reqVO));
    }

    @ApiOperation(value = "委托新增")
    @PostMapping("/add-entrust")
    public R<?> addEntrust(@RequestBody BpmEntrustEx entity) {
        return R.ok(bpmEntrustExService.addEntrust(entity));
    }
    
    @ApiOperation(value = "委托修改")
    @PutMapping("/update-entrust")
    public R<?> updateEntrust(@RequestBody BpmEntrustEx entity) {
        return R.ok(bpmEntrustExService.updateEntrust(entity));
    }

    @ApiOperation("删除委托")
    @DeleteMapping("/delete-entrust/{ids}")
    public R<?> deleteEntrust(@PathVariable(value = "ids") Long[] ids){
        return R.ok(bpmEntrustExService.deleteEntrust(ids));
    }

    @ApiOperation("获取委托信息")
    @GetMapping("/get-entrust-info")
    public R<?> getEntrustInfo(@Valid BpmEntrustInfoReqVO reqVO) {
        return R.ok(bpmEntrustExService.getEntrustList(reqVO));
    }
    
    @ApiOperation(value = "获取委托人", notes = "查询是否有委托 有的话替换原来的人 没有返回原来的人")
    @GetMapping("/get-entrust-users")
    public R<?> getEntrustUsers(@Valid BpmEntrustInfoReqVO reqVO) {
        return R.ok(bpmEntrustExService.getEntrustUserSet(reqVO));
    }
    
    
}
